package jgo.plugins.middleware;

import jgo.Context;
import jgo.Handler;
import jgo.JGo;
import jgo.core.MiddlewarePlugin;

public class LoggingMiddleware extends MiddlewarePlugin {

    @Override
    public void handle(Context ctx, Handler next) {
        long startTime = System.currentTimeMillis();
        logger.info("开始处理请求: {} {}", ctx.getMethod(), ctx.getPath());

        next.handle(ctx);

        long endTime = System.currentTimeMillis();
        logger.info("请求处理完成: {} {} - 耗时: {}ms", ctx.getMethod(), ctx.getPath(), endTime - startTime);
    }
    
    public static void main(String[] args) {
    	JGo.one().use(new LoggingMiddleware());
	}
}